//
//  UIImageView+BlurEffect.m
//  TestDemo
//
//  Created by InitialC on 16/11/29.
//  Copyright © 2016年 Mr.C. All rights reserved.
//

#import "UIImageView+BlurEffect.h"

@implementation UIImageView (BlurEffect)

- (UIImageView *)blurEffectForImageV:(UIImageView *)bottomImageV withEffect:(UIBlurEffectStyle)blurStyle {
    UIBlurEffect *effect = [UIBlurEffect effectWithStyle:blurStyle];
    UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect];
    effectView.frame = bottomImageV.bounds;
    
    // 加上以下代码可以使毛玻璃特效更明亮点
    UIVibrancyEffect *vibrancyView = [UIVibrancyEffect effectForBlurEffect:effect];
    UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:vibrancyView];
    visualEffectView.translatesAutoresizingMaskIntoConstraints = NO;
    [effectView.contentView addSubview:visualEffectView];
    
    [bottomImageV addSubview:effectView];
    return bottomImageV;
}

@end
